package com.liu.controller;

import com.liu.domain.build;
import com.liu.repository.BuildRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by liu on 17-9-22.
 */
@RestController
public class BuildController {
    private final static Logger logger = LoggerFactory.getLogger(BuildController.class);

    @Autowired
    private BuildRepository buildRepository;

    /*
    查询所有列表
     */
    @GetMapping(value = "/build")
    public List<build> buildList(){
        System.out.println("buildList");

        logger.info("buildList");

        return buildRepository.findAll();

    }
    /*
    添加
     */
    @PostMapping(value = "/build")
    public build buildAdd(build build) {


        return buildRepository.save(build);
    }

    /*
    更新一个
     */
    @PutMapping(value = "/build/{build_id}")
    public build buildUpdate(@PathVariable("build-") Integer build_id, build build) {

        return buildRepository.save(build);
    }
    /*
    删除一个
     */

    @DeleteMapping(value = "/build/{build_id}")
    public void buildDelete(@PathVariable("build") Integer build_id){
        buildRepository.delete(build_id);
    }

}
